﻿using FluentNHibernate.Mapping;
using easyccms.BusinessLayer.Entities;

namespace easyccms.Nhibernate.Mappings
{
    /// <summary>
    /// Mapping of menu item.
    /// </summary>
    public class MenuMap : ClassMap<Menu>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuMap"/> class.
        /// </summary>
        public MenuMap()
        {
            Table("dbo.Menu");
            Id(x => x.MenuId,"MenuId");
            Map(x => x.Name);
            Map(x => x.MenuOrder).Default("0");
            Map(x => x.Alt);
            Map(x => x.CheckedOut);
            Map(x => x.CheckedOutTime);
            HasOne(x => x.UserGroup).Cascade.None();
            Map(x => x.ContainerName);
            Map(x => x.Created);
            Map(x => x.Deleted);
            HasMany(x => x.MenuItems).Inverse().KeyColumn("MenuId").Cascade.None();
            References(x => x.User).Column("UserId").Cascade.None();
        }
    }
}